Code.require_file Path.expand("./support/dummy_definition.exs", __DIR__)

defmodule CofferTest do
  use ExUnit.Case
  alias CofferTest.DummyDefinition

  doctest Coffer

  @original_path Path.expand("support/image.png", __DIR__)

  setup do
    Application.put_env(:coffer, :storage, Coffer.Storage.Local)
  end

  test "it works" do
    result = DummyDefinition.store(@original_path)
    for version <- DummyDefinition.versions do
      {:ok, file} = result |> Enum.find(fn {:ok, file} -> file.version == version end)
      assert File.exists?(file.storage_path)
      File.rm!(file.storage_path)
    end
  end
end
